﻿import AS2.XmlLogFile;
import mx.utils.Delegate;
class comboDataV1 {
	//-----------------------------
	// 预备 
	var xmlOK = 0;
	// 
	var cbSet:Object = {};
	//
	var UO = AS2.Util_Object;
	var callback:Function;
	var id:String;
	var data = {};
	var scope;
	//
	function comboDataV1(scope:MovieClip, id:String, url:String, callback:Function) {
		//-----------------------------
		// 跑
		this.scope = scope;
		this.id = id;
		this.callback = callback;
		var myxmlloader:XmlLogFile = new XmlLogFile(url);
		myxmlloader.addEventListener("my_event", Delegate.create(this, doP));
	}
	function doP(tar) {
		var obj = tar.target;
		// 
		if (obj.cb._type == 'array') {
			for (var i = 0; i<obj.cb.length; i++) {
				var oo = obj.cb[i];
				cbSet[oo.id] = {};
				UO.copy(cbSet[oo.id], oo);
				do_css(oo, oo.id);
				do_sel(oo, oo.id);
			}
		}
		UO.traceObj(cbSet[oo.id].sel);
		//AS2.Util_Object.traceObj(css1);
		//AS2.Util_Object.traceObj(css2);
		//AS2.Util_Object.traceObj(cb_data);
		// trace('arr1 -> '+arr1);
		// trace('arr2 -> '+arr2);
		trace('!!comboDataV1 - 加载XML OK'+this.callback);
		xmlOK = true;
		Delegate.create(scope, callback)();
		// STEP 6 播放下一帧 
	}
	function do_css(obj, id) {
		if (obj.css._type == 'array') {
			for (var i = 0; i<obj.css.length; i++) {
				var oo = obj.css[i];
				cbSet[id][oo.id] = oo.vv;
				//trace(oo.id)                         
				//trace(oo.vv)
			}
		}
	}
	function do_sel(obj, id) {
		cbSet[id].sel = [];
		if (obj.sel._type == 'array') {
			for (var i = 0; i<obj.sel.length; i++) {
				var oo = (obj.sel[i]);
				cbSet[id].sel.push(oo.vv);
			}
		}
	}
}
